package com.opta.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.optaplanner.core.api.score.Score;

import java.util.HashMap;
import java.util.Map;

/**
 * @author GC
 * @name SolutionResult
 * @description 引擎计算结果 最优可行解
 * @date 2020/4/23 19:03
 * @since 1.0
 */
public class SolutionResult {
    private static Map<String, Result> resultMap = new HashMap<>();

    public static void add(Result result) {
        resultMap.put(result.getBestSolution().getId(), result);
    }

    public static Result getAndRemove(String solutionId) {
        Result result = resultMap.get(solutionId);
        resultMap.remove(solutionId);
        return result;
    }

    @Data
    @AllArgsConstructor
    public static class Result {
        private OrderSolution bestSolution;
        private Score bestScore;
    }
}


